﻿@page
@model ToolGood.FlowVision.Pages.Members.Projects.IndexModel
@{
    Layout = "~/Pages/Shared/_Layout_List.cshtml";
}
<div style="overflow: hidden;">
    <div class="data-header">
        <div class="search-v2">
            <form id="search-form">
                <div class="filter">
                    <label class="label">项目：</label>
                    <input type="text" class="text" name="name" id="txt_name" autocomplete="off">
                </div>
                <div class="filter">
                    <button type="button" class="layui-btn layui-btn-xs layui-btn-normal search-btn">&nbsp; 搜索 &nbsp; </button>
                    <button type="button" class="layui-btn layui-btn-xs layui-btn-primary" onclick="pageReload()">&nbsp; 重置 &nbsp; </button>
                </div>
                <div class="filter"> | </div>
                <div class="filter">
                    <a href="./Edit?h=450&w=750" class="layui-btn layui-btn-xs layui-btn-primary openwin" title="增加新项目"> &nbsp; 增加新项目 &nbsp; </a>
                </div>
                <div style="display:inline-block">
                    <div class="filter"> | </div>
                    <div class="filter">
                        <a href="./ToolKits/InitValueTool?h=550&w=700" class="layui-btn layui-btn-xs layui-btn-primary openwin" title="小工具"> &nbsp; 小工具 &nbsp; </a>
                    </div>
                </div>
            
            </form>

        </div>
    </div>
    <div class="data-content">
        <table class="layui-hide" id="dataList" lay-filter="dataList"></table>
    </div>
</div>

<form id="delete-form" class="hidden">
    @Html.AntiForgeryToken()
    <input type="hidden" name="id" value="" />
</form>

<div style="display:none" id="bar">
    <a pass-import="@Model.ButtonPass" href="./Import?h=400&w=650&id={{ d.id }}" class="openwin" title="上传导入"> 上传导入</a>
    <span pass-import="@Model.ButtonPass">&nbsp; &nbsp;</span>
    <a pass-edit="@Model.ButtonPass" href="./Edit?h=450&w=750&id={{ d.id }}" edit class="openwin" title="编辑项目"> 编辑</a>
</div>


@section js{
    <script>
        var showBar = '@(Model.ButtonPass.CanEditOrDelete ? "1" : "0")';

        layui.use(["layer", "form", "table"], function () {
            var getListUrl = './Ajax/GetList';
            var cols = [];
            //cols.push({ checkbox: true, fixed: true });
            cols.push({ field: 'id', title: '序号', width: "80", sort: true, });
            cols.push({ field: 'name', title: '项目名称', width: "200", sort: true, });
            cols.push({ field: 'comment', title: '备注', width: "300", });
            cols.push({ field: 'modifyTime', title: '修改时间', width: "150", });

            if (showBar == '1') {
                cols.push({ field: 'right', title: '操作', width: "200", align: 'center', fixed: 'right', toolbar: '#bar' });
            }

            var tableOptions = {
                url: getListUrl,
                autoSort: false,
                size: 'sm',
                even: true,
                method: 'POST',
                cols: [cols],
                page: true,
                limit: 30,
                limits: [10, 20, 30, 50, 100],
                response: { statusCode: 1, msgName: 'message' },
                height: 'full-' + ($('.data-header').outerHeight(true) + 5),
                done: function () { layer.closeAll('loading'); },
                request: { pageName: 'pageIndex', limitName: 'pageSize' },
                text: { none: '<span style="color:red;">暂无记录</span>' }
            };

            var layer = layui.layer, table = layui.table;
            layer.load(2);
            table.init('dataList', tableOptions);
            table.on('rowDouble(dataList)', function (obj) { $(obj.tr[0]).find("a[edit]").trigger("click"); });
            table.on('sort(dataList)', function (obj) {
                layer.load(2);
                var field = obj.field; order = obj.type;
                if (obj.type == null) { field = ""; order = ""; }
                table.reload("dataList", { where: { Field: field, order: order, }, page: { curr: 1 } });
            });
            function tableReload() { layer.load(2); table.reload("dataList", { where: $("#search-form").serializeJson(), page: { curr: 1 } }); }
            $('.search-btn').click(function (event) { event && event.stopPropagation(); tableReload(); return false; });
            $("select").change(function (event) { event && event.stopPropagation(); tableReload(); return false; });
            $('.filter input').keydown(function (event) { event && event.stopPropagation(); if (event.keyCode == 13) { tableReload(); return false; } })
            $('.filter a').keydown(function (event) { event && event.stopPropagation(); if (event.keyCode == 13 && $(".layui-layer").length > 0) { return false; } })

        });
        function pageReload() {
            location.reload();
        }
        function reload() {
            layui.table.reload("dataList");
        }
    </script>
}